package com.huawei.appmarket.support.launcher;

import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import androidx.annotation.NonNull;
import com.huawei.appgallery.foundation.launcher.api.AbsLaunchInterceptor;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import o.Logger;
import o.ContentManager;

public class VRAppDefaultInterceptor extends AbsLaunchInterceptor {
    String ˊ = "EXIT_SHOW_TOAST";

    public boolean isInterceptor(@NonNull String str) {
        try {
            PackageManager packageManager = ContentManager.getInstant().getContext().getPackageManager();
            if (packageManager == null) {
                return false;
            }
            ApplicationInfo applicationInfo = packageManager.getApplicationInfo(str, DnsConfig.MAX_CACHE_ENTRIES);
            if (applicationInfo == null || applicationInfo.metaData == null) {
                return false;
            }
            if (!"vr_only".equals(applicationInfo.metaData.getString("com.huawei.android.vr.application.mode"))) {
                return false;
            }
            Logger.ˏ("AppLauncher", str + " is VR app.");
            return true;
        } catch (NameNotFoundException e) {
            Logger.e("AppLauncher", e.toString());
            return false;
        }
    }

    public Intent getIntentByPackage(Context context, String str) {
        Intent intent = new Intent();
        intent.setPackage(str);
        intent.setAction("com.huawei.android.vr.PROMPT");
        intent.putExtra(this.ˊ, false);
        return intent;
    }
}
